package com.jgzj.example.export.format;

import com.jgzj.example.export.model.UserInfoExportModel;
import com.jgzj.example.export.vo.UserInfoRspVo;
import org.apache.logging.log4j.core.util.datetime.FastDateFormat;

import java.util.function.Function;

/**
 * @description:
 * @author: 子木
 * @since: 2021/05/16
 */
public class UserInfoFormat implements Function<ExportFormatReq, UserInfoExportModel> {
    @Override
    public UserInfoExportModel apply(ExportFormatReq exportFormatReq) {

        UserInfoRspVo userInfoRspVo = (UserInfoRspVo) exportFormatReq.getData();
        UserInfoExportModel exportModel = new UserInfoExportModel();
        exportModel.setAge(userInfoRspVo.getAge() + "");
        exportModel.setUid(userInfoRspVo.getUid());
        exportModel.setName(userInfoRspVo.getName());
        exportModel.setPassword("******");
        FastDateFormat dateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
        exportModel.setCreateAt(dateFormat.format(userInfoRspVo.getCreateAt()));
        exportModel.setUpdateAt(dateFormat.format(userInfoRspVo.getUpdateAt()));
        return exportModel;
    }
}